package com.ccs.testcase;

import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.openqa.selenium.WebDriver;

import com.ccs.functions.Login;
import com.ccs.functions.Logout;
import com.ccs.functions.Webdriver;
import com.ccs.loas.CreateLOA;
import com.ccs.loas.Miscellaneous;


@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class Loa_Invalid_Tests {

	public static String appCode;
	private static String loa_number;
	private static WebDriver driver;
	private static String pin;
	
	@BeforeClass
	public static void startBrowser()throws Exception{
		Webdriver d = new Webdriver();
		driver = d.startUp();
	}
	
	@Test
	public void a_login_app() throws Exception{
		System.out.println("Start Test: LOGIN WEBAPP");
		Login in = new Login();
		in.app(driver);
		System.out.println("End Test: LOGIN WEBAPP\n");
	}
	@Test
	public void b_loa_onload_approved() throws Exception{
		System.out.println("Start Test: Onload Loa - APPROVED");
		Miscellaneous m = new Miscellaneous();
		m.onload_loa_page(driver);
		System.out.println("End Test: Onload Loa - APPROVED\n");
	}
	@Test
	public void c_create_loa_invalid_dates() throws Exception{
		System.out.println("Start Test: Invalid Dates on Search Create Loa");
		Miscellaneous m = new Miscellaneous();
		m.invalid_dates(driver);
		System.out.println("End Test: Invalid Dates on Search Create Loa\n");
	}
	@Test
	public void d_clear_search_loa() throws Exception{
		System.out.println("Start Test: Clear on Search Create Loa");
		Miscellaneous m = new Miscellaneous();
		m.clear_tab_search_loa(driver);
		System.out.println("End Test: Clear on Search Create Loa\n");
	}
	@Test
	public void e_create_loa_cancel() throws Exception{
		System.out.println("Start Test: Cancel Button on Create Loa Search");
		Miscellaneous m = new Miscellaneous();
		m.cancel_button_loa_create_search(driver);
		System.out.println("End Test: Cancel Button on Create Loa Search\n");
	}
	@Test
	public void f_create_loa() throws Exception{
		System.out.println("Start Test: Create Loa");
		Miscellaneous m = new Miscellaneous();
		m.go_to_Loa(driver);
		CreateLOA loa = new CreateLOA();
		String returnedString = loa.create(driver, "notcovered");
		String[] arrString = returnedString.split(",");
		loa_number = arrString[1];
		pin = arrString[0];
		System.out.println("Loa Number: "+loa_number);
		System.out.println("End Test: Create Loa\n");
	}
	@Test
	public void g_search_loa() throws Exception{
		System.out.println("Start Test: Verify Searching Functions of LOA");
		Logout out = new Logout();
		out.app(driver);
		Login in = new Login();
		in.app(driver);
		Miscellaneous m = new Miscellaneous();
		m.go_to_Loa(driver);
		m.search_functions_loa(driver, "loa_number", loa_number);
		m.search_functions_loa(driver, "pin", pin);
		m.search_functions_loa(driver, "last_name", "Cocolife");
		m.search_functions_loa(driver, "quezoncity", "");
		m.search_functions_loa(driver, "approved", "");
		m.search_functions_loa(driver, "disapproved", "");
		m.search_functions_loa(driver, "slmc", "");
		m.search_functions_loa(driver, "reissued", "");
		m.search_functions_loa(driver, "new", "");
		m.search_functions_loa(driver, "pending", "");
		System.out.println("End Test: Verify Searching Functions of LOA\n");
	}
	@Test
	public void h_end_driver() throws Exception{
		Miscellaneous m = new Miscellaneous();
		m.end_driver(driver);
	}
	
}
